package com.finstone.data.spider.eshop.service.impl;

import com.finstone.data.spider.eshop.pipeline.EShopPagePipline;
import com.finstone.data.spider.eshop.processor.EShopPageProcessor;
import com.finstone.data.spider.eshop.service.AbstractSpiderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import us.codecraft.webmagic.Request;
import us.codecraft.webmagic.Spider;

import javax.annotation.PostConstruct;

@Component
public class EShopPageService extends AbstractSpiderService<String> {

	@Autowired
	private EShopPageProcessor eShopPageProcessor;

	@Autowired
	private EShopPagePipline eShopPagePipline;

	@Override
	@PostConstruct
	public void init() {
		spider = Spider.create(eShopPageProcessor).addPipeline(eShopPagePipline).thread(5);
	}

	@Override
	protected void doPutTask(String url) {
		Request request = new Request(url);
		spider.addRequest(request);
//		spider.addUrl(url);
	}


}
